package org.m3.puzzle;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.AbsoluteLayout;
import android.widget.ImageView;
import android.widget.AbsoluteLayout.LayoutParams;


public class Block extends ImageView {
	private int top;
	private int left;
	private int height;
	private int width;
	private int sequence;
	
	public Block(Context context, int left, int top, int width, int height, Bitmap bitmap, int sequence) {
		super(context);
		this.top = top;
		this.left = left;
		this.width=width;
		this.height=height;
		this.sequence = sequence;
		this.setImageBitmap(Bitmap.createBitmap(bitmap, left, top, width, height));
	}
		
	public LayoutParams getViewLayoutParams(){
		return new LayoutParams(width,height,left,top);
	}

	public boolean isTapped(float  x, float y){
		return (x>left && x<(left+getWidth()) && y>top && y < (top+getHeight()));
	}
	
	public void setTop(int top) {
		this.top = top;
	}

	public void setLeft(int left) {
		this.left = left;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	public int getSequence() {
		return sequence;
	}
	
}
